/**
 *Copyright (c) 2024 watereyes
 * safetymanagement is licensed under Mulan PubL v2.
 * You can use this software according to the terms and conditions of the Mulan
 * PubL v2.
 * You may obtain a copy of Mulan PubL v2 at:
 *          http://license.coscl.org.cn/MulanPubL-2.0
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PubL v2 for more details.
 */
package com.koron.hazardsource.mapper;

import com.koron.hazardsource.domain.CheckListEntry;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.koron.ebs.mybatis.EnvSource;

import java.util.List;


public interface CheckListEntryMapper {
    /**
     * 根据主键获取检查表信息
     * @param tableName
     * @param id
     * @return
     */
    CheckListEntry queryOne(@Param("tableName") String tableName,@Param("id") String id);

    /**
     * 根据指定条件查询检查表列表数据
     * @param tableName
     * @param businessTypeId
     * @param name
     * @param checklistEntryTypeId
     * @param start
     * @param rows
     * @return
     */
    List<CheckListEntry> queryByCondition(@Param("tableName") String tableName,@Param("businessTypeId") String businessTypeId,@Param("name")String name,
                                          @Param("checklistEntryTypeId")String checklistEntryTypeId,@Param("start")Integer start,@Param("rows")Integer rows);

    /**
     * 根据指定条件统计标准检查表总数
     * @param tableName
     * @param businessTypeId
     * @param name
     * @param checklistEntryTypeId
     * @return
     */
    Integer countByCondition(@Param("tableName") String tableName,@Param("businessTypeId") String businessTypeId,@Param("name")String name,
                             @Param("checklistEntryTypeId")String checklistEntryTypeId);

    /**
     * 新增标准检查表
     * @param tableName
     * @param bean
     * @return
     */
    Integer insert(@Param("tableName") String tableName,@Param("bean") CheckListEntry bean);

    /**
     * 批量新增标准检查表
     * @param tableName
     * @param entryList
     * @return
     */
    Integer batchInsert(@Param("tableName") String tableName,@Param("entryList") List<CheckListEntry> entryList);
    /**
     * 修改标准检查表
     * @param tableName
     * @param bean
     * @return
     */
    Integer update(@Param("tableName") String tableName,@Param("bean") CheckListEntry bean);

    /**
     * 批量修改标准检查表
     * @param tableName
     * @param entryList
     * @return
     */
    Integer batchUpdate(@Param("tableName") String tableName,@Param("entryList") List<CheckListEntry> entryList);

    /**
     * 根据危险源编码查询标准检查表
     * @param tableName
     * @param code
     * @return
     */
    CheckListEntry queryByCode(@Param("tableName") String tableName,@Param("code") String code);

    /**
     * 批量删除标准检查表
     * @param tableName
     * @param idList
     * @return
     */
    Integer batchDelete(@Param("tableName") String tableName,@Param("idList") List<String>idList);

    /**
     * 根据主键列表查询符合条件的标准检查表信息
     * @param tableName
     * @param idList
     * @return
     */
    List<CheckListEntry> queryByIdList(@Param("tableName") String tableName,@Param("idList") List<String>idList);
    
    
    Integer updateState(@Param("codeList") List<String> codeList,@Param("state")int state);
    
    Integer  updateFstatusflag(@Param("idList") List<String> idList,@Param("fstatusflag") int fstatusflag);
    
    List<CheckListEntry> getDraftList(@Param("userCode") String userCode);
    List<CheckListEntry> queryHstory(@Param("code") String code);
    
    @Delete("delete from checklist_entry_history where id=#{id}")
    Integer deleteDraft(@Param("id") String id);
    
    @Update("update checklist_entry_history set code=#{code} where id=#{id}")
    Integer updateCode(@Param("id") String id,@Param("code") String code);
    
}
